package com.masterclient.app.businessmodule.minemodule.address.adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.bean.address.AddressBean;
import com.masterclient.app.R;

import butterknife.BindView;

import static com.masterclient.app.R.id.tv_address;

/**
 * 作者：sean
 * 创建时间：2017/7/28 17:47
 * 功能说明：
 */

public class AddressAdapter extends BaseQuickAdapter<AddressBean.DataBean.ShItemsBean, BaseViewHolder> {


    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_tel)
    TextView tvTel;
    @BindView(tv_address)
    TextView tvAddress;
    @BindView(R.id.cb_check)
    CheckBox cbCheck;
    private String isPurchase = "0";

    public AddressAdapter(String isPurchase) {
        super(R.layout.item_address);
        this.isPurchase = isPurchase;
    }

    @Override
    protected void convert(BaseViewHolder helper, AddressBean.DataBean.ShItemsBean item) {
        helper.setText(R.id.tv_name,item.getSh_full_name());
        helper.setText(R.id.tv_tel,item.getSh_mobile()+"");
        TextView tv_address = helper.getView(R.id.tv_address);
        CheckBox checkBox = helper.getView(R.id.cb_check);
        TextView tv_default = helper.getView(R.id.tv_default);
        checkBox.setClickable(false);

        if("1".equals(item.getSh_is_default())){
            tv_default.setVisibility(View.VISIBLE);
            checkBox.setChecked(true);
        }else {
            tv_default.setVisibility(View.GONE);
            checkBox.setChecked(false);
        }
        tv_address.setText(item.getSh_province()+" "+item.getSh_city()+" "+item.getSh_area()+" "+item.getSh_address());
        if(helper.getLayoutPosition() == 0){
            helper.getView(R.id.v_gap).setVisibility(View.GONE);
        }
        helper.addOnClickListener(R.id.rl_con);
    }
}
